--handles removal of entities.
local priority = 2

EntitySystem.updatesystem("cleanup", priority, function(dt) 
    --rm time over
    for e in pairs(EntitySystem.query("timed")) do
      e.duration.remaining = e.duration.remaining - dt
      
      if e.duration.remaining <= 0 then
        EntitySystem.delete(e)
      end
    end
    
end)

--onDeath actions
function spawn(components) --spawn new entity with given components
  EntitySystem.entity(components)
end
 